<template>
	<view class="box">
		<view v-if="this.orderForm.id==0">
			<u-empty       text="未查询到订单详情"    icon="https://cdn.uviewui.com/uview/empty/history.png"></u-empty>
		</view>
		<view v-else>
			
			<view >
				<watermark-camera :imgNumber="3" @clickTakePhoto="clickTakePhoto"
				 :userName="orderForm.userName"
				 :serviceName="orderForm.serveName"  @takePhotoSubmit="takePhotoSubmit"></watermark-camera>
			</view>
			
		</view>
		
	</view>
</template>

<script>
	import watermarkCamera from "@/components/watermark-camera/watermark-camera";
import { onUpdated } from "vue";
	export default {
		components: {
		    watermarkCamera
		},
		data() {
			return {
				getHeight:"600",
				imgList:[],
				fileList:[],
				itme:{},
				isAll:false,
				orderForm:{
					type:1,
					zong:"20",
					pointmentMoneya:"20",
					tailMoneya:"",
					id:0,
				},
			}
		},
		onLoad(e) {
			console.log(JSON.stringify(e.orderId))
			console.log(JSON.stringify(e.id))//84：13
			this.show(e.orderId,e.id)
		},
		methods: {
			show(orderId,dispatchRecordId){
				this.request.getRequest(this.http.httpsLian.homemakingOrderGetId,{id:orderId})
				.then(res => { 
					console.log("服务完成单res",res)
					if(res.code!=0 )return 
					this.orderForm = res.data;
					this.orderForm.finalPrice=(this.orderForm.finalPrice/100).toFixed(2);
					this.orderForm.dispatchRecordId = dispatchRecordId // 派单记录ID
					this.isAll = this.orderForm.managementPayType == 0 ? true : false;//是否全款
				}).catch(res => {
					uni.$u.toast(res)
				})
			},
			//点击上传
			takePhotoSubmit(url){
				console.log('点击上传：' +JSON.stringify(url));
				let datas=JSON.parse(JSON.stringify(this.orderForm))
				datas.signaturePicUrl=JSON.stringify(url)
				datas.isAll=this.isAll
				datas.finalPrice=0;
				console.log("服务已完成",JSON.stringify(datas))
				this.post(datas,"服务已完成")
				
			},
			post(datas,msg){
				let this_=this
				this.request.postRequest(this.http.httpsLian.homemakingOrderSubmitFinalPrice,datas,true)
				.then(res => { 
					console.log("尾款返回:"+JSON.stringify(res))
					let iconMsg;
					if(res.code==0)iconMsg=true;
					if(res.code!=0)iconMsg=false;
					uni.showToast({
						title:iconMsg?msg:'提交失败',
						icon:iconMsg?"success":"error",
						duration: 1800
					})
					setTimeout(() => {
						var pages = getCurrentPages(); // 获取当前挂载的路由数组
						var prePage = pages[pages.length - 2] //获取 上一个页面
						uni.navigateBack({
							data:1,
							success(event) {
								prePage.$vm.reload() // 当返回成功的时候调用上一级页面的回调
							}
						})
					}, 1900)
				}).catch(res => {
					uni.$u.toast("网络异常10")
				})
			},
			//点击拍照返回
			 clickTakePhoto(url,urlList){
				console.log('点击拍照返回：' +url.imgList);
			},
			//服务完成 H2025030500002 639
			
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			pickerClose(){
				this.pickerShow=false;
			},
			//修改备注
			updateOrte(){
				
			}
			
		}
	}
</script>

<style lang="scss" scoped>
.box{
	margin-top: 10rpx;
	padding: 0px 10px;
	//background-color: white;
}	
.fontweight{
	font-weight: 550;
}
.content1{
	margin-top: 20px;
	/deep/.u-upload__button{
		background-color: white;
		
	}
	view{
		margin-top: 10px;
	}
}
span{
	font-size: 11px;
	color: $uni-text-color-grey;
}
p{
	font-size: 12px;
}
.bottom{
	background: white;
	padding: 10px;
	
	/deep/.u-input{
		width: 120px !important;
		//background-color: rgb(245, 247, 250);
	}
	
	.fontweight{
		margin-bottom: 20px;
	}
}
/deep/.u-button{
	    color: black !important;
		margin-top: 20px;
		margin-bottom: 20px;
	}
	.reservation{
		background-color: white;
		padding: 10px 0px;
	}
</style>
